home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / sndpas.zip / SOUNDEFF.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-22  |  3KB  |  113 lines

  1. { Sound Effects
  2.  
  3. Written by:
  4.  
  5.     Nels Anderson
  6.    92 Bishop Drive
  7. Framingham, MA  01701
  8.  
  9. Released to the public domain
  10. }
  11.  
  12. {
  13. Modified by:
  14.  
  15.     Stephane Cote
  16.     660 Labarre
  17.     Hebertville, Quebec, Canada
  18.     G0W 1S0
  19. }
  20.  
  21. unit SoundEff;
  22.  
  23. interface
  24.  
  25. Uses
  26.   Crt;
  27.  
  28. procedure SndEff(Info:  POINTER);
  29.  
  30. Const
  31.   Bat: array[1..5] of INTEGER = (
  32.   12000,-100,6,106,0);
  33.   BirdCall: array[1..13] of INTEGER = (
  34.   3500,0,50,1,
  35.   3000,0,50,1,
  36.   4000,0,50,1,0);
  37.   ClockTick: array[1..9] of INTEGER = (
  38.   12500,0,19,1,
  39.   -1,0,1000,1,0); {uses frequency of -1 for silence}
  40.   Conveyor: array[1..5] of INTEGER = (
  41.   37,1,3,64,0);
  42.   Crickets: array[1..13] of INTEGER = (
  43.   1800,0,3,10,
  44.   2000,0,1,1,
  45.   -1,0,100,1,0);
  46.   DoorBuzzer: array[1..5] of INTEGER = (
  47.   5700,1500,1,7,0);
  48.   Explosion: array[1..5] of INTEGER = (
  49.   300,150,6,10,0);
  50.   PhoneRing: array[1..9] of INTEGER = (
  51.   523,0,28,1,
  52.   659,0,28,1,0);
  53.   FlyingSaucer: array[1..5] of INTEGER = (
  54.   500,200,28,5,0);
  55.   Siren: array[1..9] of INTEGER = (
  56.   200,1,2,800,
  57.   1000,-1,2,800,0);
  58.   Drip: array[1..9] of INTEGER = (
  59.   1000,100,8,3,
  60.   -1,0,600,1,0);
  61.   Train: array[1..5] of INTEGER = (
  62.   1700,-4,1,416,0);
  63.   Whoop: array[1..5] of INTEGER = (
  64.   900,1,5,100,0);  
  65.   Phaser: array[1..5] of INTEGER = (
  66.   300,100,6,15,0);
  67. Type
  68.   {
  69.     You must modify the number 13 below so that
  70.     it equals the number of cells in the biggest
  71.     array of the constants above.
  72.   }
  73.  
  74.   IntArray = array[1..13] of INTEGER;
  75.  
  76. implementation
  77.  
  78. procedure SndEff(Info:  POINTER);
  79. { Generate sounds according to the Info table.  Each table entry contains the
  80.   following:
  81.  
  82.       Starting Tone in Hz
  83.       Freq. change in Hz per repetition
  84.       Milliseconds between changes
  85.       Number of repetitions
  86.  
  87.   The table can repeat these parameters as many times as necessary.  To end
  88.   the table a single 0 is required.
  89. }
  90. var
  91.   Table:  ^IntArray;
  92.   i,tone,
  93.   offset:  INTEGER;
  94. begin
  95.   offset := 0;                    {init. offset into table}
  96.   Table := Info;                {set pointer}
  97.   repeat
  98.     tone := Table^[offset+1];            {get initial tone}
  99.     for i := 1 to Table^[offset+4] do begin    {for each repetition...}
  100.       if tone < 0 then
  101.         NoSound
  102.       else
  103.         Sound(tone);                {start a sound}
  104.       Delay(Table^[offset+3]);            {set duration}
  105.       tone := tone + Table^[offset+2];        {change tone}
  106.     end; {for i}
  107.     offset := offset + 4;            {increment offset into table}
  108.   until Table^[offset+1] = 0;            {until end of table}
  109.   NoSound;
  110. end; {SoundEff procedure}
  111.  
  112. end.
  113.